<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js判断类型</title>
</head>
<body>
<script>
    let bool = true;
    let num = 1;
    let str = 'abc';
    let und = undefined;
    let nul = null;
    let arr = [1, 2, 3, 4];
    let obj = {name: 'xiaoming', age: 22};
    let fun = function () {
        console.log('hello')
    };
    let s1 = Symbol();
    console.log("=================================")
    console.log(typeof bool); //boolean
    console.log(typeof num);//number
    console.log(typeof str);//string
    console.log(typeof und);//undefined
    console.log(typeof nul);//object
    console.log(typeof arr);//object
    console.log(typeof obj);//object
    console.log(typeof fun);//function
    console.log(typeof s1); //symbol
    console.log("=================================")
    console.log(bool instanceof Boolean);// false
    console.log(num instanceof Number);// false
    console.log(str instanceof String);// false
    console.log(und instanceof Object);// false
    console.log(nul instanceof Object);// false
    console.log(arr instanceof Array);// true
    console.log(obj instanceof Object);// true
    console.log(fun instanceof Function);// true
    console.log(s1 instanceof Symbol);// false
    console.log("=================================")
    console.log(bool.constructor === Boolean);// true
    console.log(num.constructor === Number);// true
    console.log(str.constructor === String);// true
    console.log(arr.constructor === Array);// true
    console.log(obj.constructor === Object);// true
    console.log(fun.constructor === Function);// true
    console.log(s1.constructor === Symbol);//true
    console.log("=================================")
    console.log(Object.prototype.toString.call(bool));//[object Boolean]
    console.log(Object.prototype.toString.call(num));//[object Number]
    console.log(Object.prototype.toString.call(str));//[object String]
    console.log(Object.prototype.toString.call(und));//[object Undefined]
    console.log(Object.prototype.toString.call(nul));//[object Null]
    console.log(Object.prototype.toString.call(arr));//[object Array]
    console.log(Object.prototype.toString.call(obj));//[object Object]
    console.log(Object.prototype.toString.call(fun));//[object Function]
    console.log(Object.prototype.toString.call(s1)); //[object Symbol]
    console.log("===================================")
</script>
</body>
</html>